package com.sinosoft.vaccinetoai.exception;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 业务异常类
 * @author xzh
 * @date 2022-10-24 11:05
 * @since 5.0.0
 */
@Getter
@Setter
@ToString
public class BusinessException extends RuntimeException {

    public BusinessException() {
        super();
    }

    public BusinessException(int code) {
        super();
        this.code = code;
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BusinessException(int code, String message, Object data) {
        super(message);
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static BusinessException ofExceptionEnums(ExceptionEnums enums) {
        return new BusinessException(enums.getCode(), enums.getMessage());
    }

    public static BusinessException ofExceptionEnums(ExceptionEnums enums, Object data) {
        return new BusinessException(enums.getCode(), enums.getMessage(), data);
    }

    //异常码
    private int code;

    //异常信息
    private String message;

    //数据
    private Object data;

}
